<template>
    <el-dialog append-to-body :close-on-click-modal="false" :before-close="cancel" :visible.sync="visible" title="备注"
        width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="100px">
            <el-form-item label="备注信息" prop="reservationDesc">
                <el-input v-model="form.reservationDesc" placeholder="请输入备注信息" size="small" clearable />
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="text" @click="cancel">取消</el-button>
            <el-button :loading="loading" type="primary" @click="submitClick">确认</el-button>
        </div>
    </el-dialog>
</template>

<script>
import * as ajax from "@/api/treatmentProject/app.js";
export default {
    name: "descModal",
    data() {
        return {
            visible: false,
            form: { reservationId: undefined, reservationDesc: "" },
            loading: false,
            rules: {
                reservationDesc: [
                    { required: true, message: "请输入备注信息", trigger: "blur" },
                ],
            },
        };
    },
    mounted() { },
    methods: {
        showModal(id, desc) {
            this.visible = true;
            this.form.reservationId = id;
            this.form.reservationDesc = desc;
        },
        submitClick() {
            this.$refs.form.validate().then(() => {
                this.loading = true;
                ajax
                    .descReservation(this.form)
                    .then((res) => {
                        this.$emit("search");
                        this.cancel();
                        this.$notify({
                            title: "添加备注成功",
                            type: "success",
                            duration: 2500,
                        });
                        this.loading = false;
                    })
                    .catch((res) => {
                        this.loading = false;
                        this.$notify({
                            title: res.msg,
                            type: "error",
                            duration: 2500,
                        });
                    });
            });
        },
        cancel() {
            this.visible = false;
        },
    },
};
</script>

<style lang='scss' scoped></style>